Skip to content

rrbanda/dataloader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Universal DataLoader

AI-Powered Knowledge Graph Construction for Enterprise Infrastructure

License Python LangChain Neo4j Tests

Transform unstructured infrastructure data into intelligent knowledge graphs using LangChain and Neo4j. Production-ready foundation for Graph RAG, infrastructure analysis, and intelligent operations.


πŸ“– Table of Contents


🎯 Overview

What Problem Does This Solve?

Enterprise organizations struggle to extract actionable intelligence from massive amounts of unstructured infrastructure data (logs, configs, documents, incident reports). Traditional parsing creates disconnected data pointsβ€”this solution creates intelligent, queryable knowledge graphs.

Core Value Proposition

# INPUT: Raw infrastructure files
/var/log/secure, /etc/httpd/conf/httpd.conf, /var/log/yum.log...

# PROCESSING: AI semantic understanding
LangChain LLMGraphTransformer + LLM API β†’ Intelligent entity extraction

# OUTPUT: Connected knowledge graph  
(web-prod-01:Server)-[:RUNS]->(httpd:Service)
(httpd:Service)-[:DEPENDS_ON]->(openssl:Package)
(CVE-2023-12345:Vulnerability)-[:AFFECTS]->(openssl:Package)

# CAPABILITY: Graph RAG queries
"Which production servers are affected by the latest OpenSSL vulnerability?"

Key Benefits

  • 🧠 AI-Powered: Semantic understanding via LLMs, not brittle regex patterns
  • πŸ”— Intelligent Relationships: Auto-discovers complex dependencies and connections
  • 🎯 Graph RAG Ready: Perfect foundation for intelligent retrieval systems
  • 🌍 Domain Agnostic: Works with IT infrastructure, security, business processes, documents
  • ⚑ Production Scale: Handles enterprise workloads (1000+ systems, 15K+ entities)
  • πŸ”’ Enterprise Ready: Security, configuration management, monitoring integration

🧭 Foundational Concepts

For Users New to Graph Databases and Knowledge Graphs

If you're new to graph databases, Neo4j, or knowledge graphs, this section explains the fundamental concepts from the ground up.

πŸ—ƒοΈ Traditional vs Graph Databases

Traditional Databases (Tables):

servers.csv          services.csv         packages.csv
server_id | status   service_id | port    package_id | version
web-01   | active    httpd     | 80       openssl   | 3.0.1
db-02    | active    mysql     | 3306     httpd     | 2.4.53

Problem: Data is disconnected. Hard to answer "Which servers use vulnerable OpenSSL?"

Graph Database (Connected):

    [Analytics-Dev-648] ──HOSTS──> [Httpd] ──USES──> [Httpd-Tools]
            β”‚                                         ↑
            └──────HOSTS──> [Mysql] ──USESβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Solution: Everything is connected. Easy to trace relationships and dependencies.

πŸ”— What is Neo4j?

Neo4j is a graph database that stores data as nodes (things) and relationships (how things connect):

  • Node: A "thing" in your data (server, service, package, person, etc.)
  • Relationship: How two nodes connect (HOSTS, RUNS, USES, DEPENDS_ON, etc.)
  • Property: Details about nodes (in your system: id for identification)

Think of it like a social network for your infrastructure:

[You] ──FRIENDS_WITH──> [Person] ──WORKS_AT──> [Company]
[Analytics-Dev-648] ──HOSTS──> [Httpd] ──USES──> [Httpd-Tools]

🧠 What is a Knowledge Graph?

A knowledge graph is a smart way to organize information so computers can understand relationships and answer complex questions.

Example with your RHEL systems:

Raw Data (what you have):

/var/log/messages: "httpd started on Analytics-Dev-648"
/var/lib/rpm/packages.txt: "httpd-tools-2.4.53 installed"
/etc/redhat-release: "Red Hat Enterprise Linux release 9.3"

Knowledge Graph (what we create):

(Analytics-Dev-648:Server) ──HOSTS──> (Httpd:Service) ──USES──> (Httpd-Tools:Package)
(Red Hat Enterprise Linux:System) ──HOSTS──> (Httpd:Service)

Smart Questions You Can Now Ask:

  • "Which servers would be affected by an Httpd-Tools vulnerability?"
  • "What services will stop if I reboot Analytics-Dev-648?"
  • "Show me all production web servers and their dependencies"

πŸ” What is GraphRAG?

GraphRAG = Graph + Retrieval Augmented Generation

Traditional RAG:

Question β†’ Search Documents β†’ Send to LLM β†’ Answer

GraphRAG:

Question β†’ Query Knowledge Graph β†’ Get Connected Data β†’ Send to LLM β†’ Smarter Answer

Example:

Question: "Which production servers are vulnerable to CVE-2023-12345?"

Traditional Search: Finds documents mentioning the CVE GraphRAG: Finds CVE β†’ traces to affected packages β†’ traces to services β†’ traces to production servers

Result: Complete impact analysis, not just document search.

βš™οΈ How Raw RHEL Data Becomes a Graph Schema

Here's how your actual RHEL system files transform into a queryable knowledge graph:

Step 1: Raw Infrastructure Files

/var/log/messages:
  "Jan 15 14:23:01 Analytics-Dev-648 systemd[1]: Started The Apache HTTP Server"
  "Jan 15 14:23:15 Analytics-Dev-648 httpd[5678]: Server configured"

/etc/redhat-release:
  "Red Hat Enterprise Linux release 9.3 (Plow)"

/var/lib/rpm/packages.txt:
  "httpd-tools-2.4.53-11.el9_2.5.x86_64"
  "dnf-4.7.0-4.el9.noarch"

Step 2: AI Analysis (LangChain + LLM)

The AI reads these files and understands:

  • "Analytics-Dev-648" is a server
  • "httpd" is a service (Apache web server)
  • "systemd" manages services
  • "httpd-tools" and "dnf" are packages
  • These things have relationships

Step 3: Graph Schema Creation

// Nodes (things discovered)
(:Server {id: "Analytics-Dev-648"})
(:Service {id: "Httpd"})
(:Package {id: "Httpd-Tools"})
(:System {id: "Red Hat Enterprise Linux"})

// Relationships (connections discovered)
(Analytics-Dev-648)-[:HOSTS]->(Httpd)
(Httpd)-[:USES]->(Httpd-Tools)
(Red Hat Enterprise Linux)-[:HOSTS]->(Httpd)

Step 4: Neo4j Storage

All this gets stored in Neo4j where you can query it:

// Find all services on production web servers
MATCH (server:Server)-[:HOSTS|RUNS]->(service:Service)
WHERE server.id CONTAINS "Web-Prod"
RETURN server.id, service.id

🎯 Why This Matters for Infrastructure

Before (Traditional):

  • Manual documentation that gets outdated
  • Siloed information in different systems
  • Hard to understand dependencies
  • Slow incident response

After (Knowledge Graph + GraphRAG):

  • Automatic discovery of relationships
  • Live, connected infrastructure map
  • Instant impact analysis
  • AI-powered intelligent operations

Real Benefits:

  • Security: "Which servers use Httpd-Tools package?" β†’ Instant answer
  • Operations: "What breaks if I restart Analytics-Dev-648?" β†’ Complete dependency map
  • Compliance: "Show me all production systems with their services" β†’ Automated audit
  • Planning: "What's the blast radius of updating Httpd?" β†’ Risk assessment

πŸ’‘ Simple Mental Model

Think of your infrastructure as a city:

  • Buildings = Servers (nodes)
  • Residents = Services (nodes)
  • Utilities = Packages (nodes)
  • Roads = Relationships (how they connect)

Traditional documentation = Static map Knowledge Graph = Live GPS with traffic data

GraphRAG = Smart city assistant that understands the whole system and can answer complex questions about traffic, dependencies, and impacts.


πŸ“š Knowledge Graph Concepts

Understanding Your RHEL Infrastructure as a Knowledge Graph

This section explains how abstract knowledge graph terminology maps to your concrete RHEL infrastructure, making it easier to understand what the system creates and how to explain it to stakeholders.

πŸ—‚οΈ Entities (Nodes) - "What Things Exist"

Knowledge Graph Term RHEL Infrastructure Meaning Your Data Examples Business Value
Entity/Node Physical or logical IT component Server, Service, Package "Things that exist in our infrastructure"
Entity Type Category of IT component Server (133), Service (41), Package (28) "Types of infrastructure components"
Properties Characteristics of components id (unique identifier) "Details about each component"
Domain Area of business/IT RHEL Infrastructure & Systems "The part of IT we're modeling"

πŸ–₯️ Your Specific Entity Types:

  • Server (133): Physical/virtual machines (Analytics-Dev-648, Web-Prod-898, Red Hat Enterprise Linux)
  • Service (41): Running processes (Httpd, Mysql, Sshd)
  • Package (28): Installed software (Yum, Dnf, Kernel)
  • Component (28): System parts (Kernel, Selinux, Storage)
  • Application (18): Business applications (Httpd, Analytics, Database)

πŸ”— Relationships (Edges) - "How Things Connect"

Knowledge Graph Term RHEL Infrastructure Meaning Your Data Examples Business Impact
Relationship/Edge How components interact Server HOSTS Service "Dependencies & connections"
Relationship Type Kind of interaction HOSTS, RUNS, USES, DEPENDS_ON "Types of dependencies"
Graph Traversal Following connections Find all services on a server "Impact analysis queries"
Path Chain of relationships Server→Service→Package→Vulnerability "Root cause analysis"

πŸ”— Your Specific Relationship Types:

  • HOSTS (258): Server physically contains service (Analytics-Dev-648 HOSTS Httpd)
  • RUNS (83): Server executes service (Web-Prod-898 RUNS Mysql)
  • USES (31): Server uses package (Server USES Package)
  • DEPENDS_ON (33): Service depends on component (Service DEPENDS_ON Component)
  • MANAGES: System controls component (AI-discovered management relationships)

🎯 Knowledge Graph Business Value

Abstract Concept RHEL Infrastructure Translation Real Business Scenario
Semantic Search "Find all web servers with SSL vulnerabilities" Security team identifies at-risk systems
Relationship Discovery "What services would break if this server fails?" Incident response planning
Graph Traversal "Trace dependency chain from user request to database" Performance troubleshooting
Entity Linking "Connect security alerts to affected applications" Automated incident correlation
Knowledge Inference "If package X is vulnerable, which servers are affected?" Proactive security patching

πŸ€– AI-Powered Transformation Example

INPUT (Raw RHEL Files):
/var/log/messages: "systemd[1]: Started The Apache HTTP Server"
/etc/redhat-release: "Red Hat Enterprise Linux release 9.3"
/var/log/yum.log: "Installed: httpd-2.4.53-11.el9_2.5.x86_64"

↓ AI ANALYSIS (LangChain LLMGraphTransformer) ↓

OUTPUT (Knowledge Graph):
({id: "Analytics-Dev-648"}:Server)-[:HOSTS]->({id: "Httpd"}:Service)
({id: "Web-Prod-898"}:Server)-[:RUNS]->({id: "Mysql"}:Service) 
({id: "Red Hat Enterprise Linux"}:System)-[:HOSTS]->({id: "Httpd"}:Service)

πŸ’Ό Explaining to Stakeholders

For IT Management:

"We've created an intelligent map of our infrastructure that automatically discovers how our 1000+ RHEL systems connect. Instead of manual documentation, AI analyzes system logs and creates a live knowledge graph showing which servers run which services, what software they depend on, and how they connect."

For Security Teams:

"The knowledge graph enables instant impact analysis. When a CVE is announced, we can immediately query: 'Which production servers use vulnerable package X?' and get answers in seconds, not hours of manual investigation."

For Operations Teams:

"We can now ask intelligent questions like 'What would break if I restart server Y?' or 'Show me all services that depend on database Z' and get complete dependency maps for planning maintenance windows."

πŸ“Š Concrete Example Query

// Business Question: "What services are hosted by web production servers?"
MATCH (server:Server)-[:HOSTS|RUNS]->(service:Service)
WHERE server.id CONTAINS "Web-Prod"
RETURN server.id, service.id

// Example Result: 
// server.id: "Web-Prod-898", service.id: "Httpd"
// server.id: "Web-Prod-898", service.id: "Mysql"

// Knowledge Graph Answer: Shows all services on production web servers
// Business Value: Instant infrastructure inventory for compliance audits

This transforms your RHEL infrastructure from "a bunch of servers" into "an intelligent, queryable knowledge system" that enables proactive IT operations!


⚑ Quick Start

Get a working knowledge graph in 15 minutes:

# 1. Clone and setup environment
git clone https://github.com/rrbanda/dataloader.git
cd dataloader
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

# 2. Setup Neo4j Desktop (required)
# Download: https://neo4j.com/download/
# Create database "dataloader-db" with password "password"
# Install APOC plugin

# 3. Configure API access
export OPENAI_API_KEY="your-llm-api-key"
export OPENAI_BASE_URL="https://llama-4-scout-17b-16e-w4a16-maas-apicast-production.apps.prod.rhoai.rh-aiservices-bu.com:443/v1"
export MODEL="llama-4-scout-17b-16e-w4a16"
export NEO4J_URI="neo4j://127.0.0.1:7687"
export NEO4J_USERNAME="neo4j"
export NEO4J_PASSWORD="password"

# 4. Generate test data and verify setup
python utils/rhel_filesystem_generator.py
python test_setup.py  # Should show 5/5 tests pass

# 5. Create your first knowledge graph
python -c "
from core.unified_dataloader import get_universal_loader
loader = get_universal_loader()
systems, events = loader.load_all_systems()
print(f' Knowledge graph created: {len(systems)} systems processed')
loader.close()
"

# 6. Explore in Neo4j Desktop Browser
# Query: MATCH (n)-[r]->(m) RETURN n, r, m LIMIT 25

Expected Result: Interactive knowledge graph with ~39 nodes and 16 relationships representing intelligent infrastructure analysis.


πŸ“‹ Prerequisites

Required Software

Required API Access

  • LLM API Key (Red Hat AI: Get key, OpenAI: Get key)
    • Create account with LLM provider β†’ API Keys section β†’ Create new key

System Requirements

  • Memory: 4GB minimum, 8GB recommended for large datasets
  • Storage: 2GB free space
  • Network: Internet access for AI API calls

πŸ› οΈ Installation

Standard Installation

# Clone repository
git clone https://github.com/rrbanda/dataloader.git
cd dataloader

# Create isolated environment
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate

# Install dependencies
pip install --upgrade pip
pip install -r requirements.txt

# Verify installation
python -c "import langchain, neo4j; print(' Dependencies installed')"

Neo4j Desktop Setup

  1. Install Neo4j Desktop β†’ Download here
  2. Create Project β†’ "dataloader-project"
  3. Add Database:
    • Name: dataloader-db
    • Password: password
    • Version: Latest 5.x
  4. Install APOC Plugin β†’ Select database β†’ Plugins β†’ APOC β†’ Install
  5. Start Database β†’ Click ▢️ button

Verify Neo4j:

lsof -i :7687  # Should show Neo4j process

βš™οΈ Configuration

Environment Variables

# LLM Configuration
export OPENAI_API_KEY="your-llm-api-key"
export OPENAI_BASE_URL="https://llama-4-scout-17b-16e-w4a16-maas-apicast-production.apps.prod.rhoai.rh-aiservices-bu.com:443/v1"
export MODEL="llama-4-scout-17b-16e-w4a16"

# Neo4j Configuration
export NEO4J_URI="neo4j://127.0.0.1:7687"
export NEO4J_USERNAME="neo4j"
export NEO4J_PASSWORD="password"
export NEO4J_DATABASE="neo4j"

Configuration File: config/data_loader_config.yaml

# Data source configuration
data_sources:
  primary_data:
    type: "filesystem"
    base_path: "simulated_rhel_systems"
    file_patterns:
      system_info: ["**/system_info.txt"]
      logs: ["**/*.log"]
      configs: ["**/*.conf", "**/*.yaml"]

# LLM configuration (environment-driven)
llm_config:
  enabled: true

# Neo4j configuration (environment-driven)
neo4j_config:
  uri: "${NEO4J_URI}"
  username: "${NEO4J_USERNAME}"
  password: "${NEO4J_PASSWORD}"
  database: "${NEO4J_DATABASE}"

πŸ”„ Complete Workflow: Data β†’ Intelligence

End-to-End Process Flow

Understanding the complete journey from raw data to intelligent knowledge graphs:

πŸ“Š STEP 1: DATA GENERATION
β”œβ”€β”€ utils/rhel_filesystem_generator.py generates realistic RHEL systems
β”œβ”€β”€ Creates 18 authentic files per system (/var/log/secure, /etc/redhat-release, etc.)
β”œβ”€β”€ NO LLM USED - Pure file system simulation
└── Output: simulated_rhel_systems/ directory with realistic data

πŸ“– STEP 2: DATA LOADING  
β”œβ”€β”€ FilesystemDataSourceAdapter reads generated files
β”œβ”€β”€ TextProcessor cleans and chunks content
β”œβ”€β”€ NO LLM USED - Traditional text processing (regex, patterns)
└── Output: Cleaned, structured text ready for AI analysis

🧠 STEP 3: KNOWLEDGE GRAPH CREATION (LLM CORE ROLE)
β”œβ”€β”€ LangChain LLMGraphTransformer analyzes cleaned text
β”œβ”€β”€ LLM identifies entities (Server, Service, Package, User, Vulnerability)
β”œβ”€β”€ LLM infers relationships (RUNS, DEPENDS_ON, USES, AFFECTS) 
β”œβ”€β”€ LLM creates semantic understanding (not just pattern matching)
└── Output: Intelligent graph nodes and relationships

πŸ—„οΈ STEP 4: NEO4J STORAGE
β”œβ”€β”€ Neo4jGraph stores LLM-extracted entities and relationships
β”œβ”€β”€ Creates queryable knowledge graph in Neo4j Desktop
β”œβ”€β”€ NO LLM USED - Direct database operations
└── Output: Interactive graph ready for Graph RAG queries

πŸ€– LLM Role Deep Dive

WHERE LLMs Are NOT Used (Traditional Processing)

# Step 1: Data Generation
rhel_generator = RHELFilesystemGenerator(num_systems=100)
rhel_generator.generate_all_systems()
#  No AI - Creates realistic file content using templates

# Step 2: Data Loading  
files = data_source.read_system_files("web-prod-01")
cleaned = text_processor.process_files(files)
#  No AI - Traditional text cleaning (remove ANSI, normalize whitespace)

# Step 4: Neo4j Storage
neo4j_graph.add_nodes(extracted_entities)
neo4j_graph.add_relationships(extracted_relationships)
#  No AI - Direct database writes

WHERE LLMs ARE CRITICAL (The Intelligence)

# Step 3: Knowledge Graph Creation (LLM CORE FUNCTION)
llm_transformer = LLMGraphTransformer(
    llm=ChatOpenAI(model="llama-4-scout-17b-16e-w4a16"),
    node_properties=["name", "type", "status"],
    relationship_properties=["type", "strength"]
)

# LLM analyzes this text:
input_text = """
Jan 15 14:23:01 web-prod-01 yum[1234]: Installed: httpd-2.4.53-11.el9_2.5.x86_64
Jan 15 14:23:15 web-prod-01 systemd[1]: Started The Apache HTTP Server
Jan 15 14:23:20 web-prod-01 httpd[5678]: AH00558: Could not reliably determine server's FQDN
"""

# LLM INTELLIGENCE CREATES:
entities = [
    Node(id="web-prod-01", labels=["Server"], properties={"environment": "production"}),
    Node(id="httpd", labels=["Service"], properties={"status": "active", "port": "80,443"}),
    Node(id="httpd-2.4.53", labels=["Package"], properties={"version": "2.4.53-11.el9_2.5"})
]

relationships = [
    Relationship(source="web-prod-01", target="httpd", type="RUNS"),
    Relationship(source="httpd", target="httpd-2.4.53", type="USES"),
    Relationship(source="package-install", target="service-start", type="PRECEDED_BY")
]

# ✨ LLM SEMANTIC UNDERSTANDING:
# - Connects package installation β†’ service start β†’ configuration warning
# - Infers web-prod-01 is a production server running Apache
# - Understands httpd = "Apache HTTP Server" = web service
# - Creates temporal relationships between events

πŸ” LLM vs Traditional Parsing Comparison

Traditional Regex Approach (Limited)

# What regex/patterns can do:
import re
log_pattern = r"(\w+\s+\d+\s+[\d:]+)\s+(\w+)\s+(\w+)\[(\d+)\]:\s+(.+)"
match = re.match(log_pattern, log_line)
#  Extracts: timestamp, hostname, service, PID, message
#  Misses: Relationships, context, semantic meaning, entity types

LLM Semantic Analysis (Intelligent)

# What LLM understanding provides:
llm_analysis = llm_transformer.convert_to_graph_documents([Document(page_content=log_line)])
#  Extracts: Entities with proper types and properties
#  Infers: Relationships between entities (RUNS, DEPENDS_ON, CAUSES)
#  Understands: Context ("httpd" = web service, needs SSL, serves HTTP traffic)
#  Creates: Temporal sequences (install β†’ start β†’ error)
#  Connects: Cross-system dependencies and impacts

πŸ“Š Real Workflow Example (100 Systems)

Step 1: Generate Enterprise Data (2 minutes)

# Generate 100 realistic RHEL systems
python utils/rhel_filesystem_generator.py 100

# Output: 1,800 files created
# /simulated_rhel_systems/
# β”œβ”€β”€ web-prod-01/var/log/secure (SSH logs)
# β”œβ”€β”€ web-prod-01/var/log/yum.log (package installs)  
# β”œβ”€β”€ db-prod-01/var/log/mysql/error.log (database logs)
# └── ... (1,800 total files)

Step 2: Load and Process Data (5 minutes)

# Read all 1,800 files, clean and structure
from core.unified_dataloader import get_universal_loader
loader = get_universal_loader()

# Traditional processing (no AI):
# - Read 1,800 files from filesystem
# - Remove ANSI codes, normalize whitespace  
# - Apply Grok patterns for log parsing
# - Chunk large files for AI processing
# Result: ~2.5MB of clean, structured text

Step 3: LLM Knowledge Graph Creation (45 minutes)

# LLM analyzes all text and creates intelligent graph
systems, events = loader.load_all_systems()

# LLM PROCESSING (the intelligence):
# - Analyzes 2.5MB of text across 100 systems
# - Identifies ~1,500 unique entities (servers, services, packages)
# - Infers ~1,200 relationships between entities
# - Creates semantic understanding of infrastructure
# - Builds temporal event sequences
# Result: Intelligent knowledge graph in Neo4j

Step 4: Query Intelligent Graph (Instant)

-- Now you can ask intelligent questions:
MATCH (s:Server)-[:RUNS]->(svc:Service)-[:USES]->(p:Package)
WHERE s.environment = 'production' AND p.name CONTAINS 'ssl'
RETURN s.hostname, svc.name, p.version

-- Find servers affected by security vulnerabilities:
MATCH (s:Server)-[:RUNS]->(svc:Service)-[:USES]->(p:Package)<-[:AFFECTS]-(v:Vulnerability)
WHERE v.severity = 'Critical'
RETURN s.hostname, v.cve_id, p.name

🎯 Key Insight: Where Intelligence Happens

# WITHOUT LLM (Traditional):
Data β†’ Pattern Matching β†’ Disconnected Records
# Limited to what you explicitly program

# WITH LLM (Intelligent):  
Data β†’ Semantic Understanding β†’ Connected Knowledge Graph
# Discovers relationships and context you didn't program

The LLM is the bridge that transforms raw infrastructure data into intelligent, queryable knowledge! 🧠


🏒 Enterprise Integration

Works WITH Your Existing Infrastructure

The Universal DataLoader is designed to complement, not replace your existing enterprise tools. Here's how it integrates with common infrastructure:

🀝 No Conflicts with Existing Tools

# Your existing infrastructure (unchanged)
Red Hat Insights    ──→ Security recommendations & compliance
Splunk/ELK         ──→ Centralized logging & search  
Prometheus/Grafana ──→ Metrics monitoring & alerting
rsyslog/fluentd    ──→ Log collection & forwarding
SIEM tools         ──→ Security event correlation

# Universal DataLoader adds:
Knowledge Graph    ──→ AI-powered infrastructure intelligence
Graph RAG          ──→ Intelligent operations & queries

πŸ“– Read-Only Data Access

The dataloader only reads existing files - it never modifies or interferes:

# What it reads (read-only access):
/var/log/messages      #  Standard syslog files
/var/log/secure        #  SSH authentication logs  
/var/log/yum.log       #  Package installation logs
/etc/redhat-release    #  System version info
/proc/cpuinfo         #  Hardware information

# What it NEVER touches:
- Log collection configurations (rsyslog.conf)
- Red Hat Insights client settings  
- Active databases or services
- Network configurations
- Security policies

πŸ”„ Integration Scenarios

Scenario 1: Alongside Red Hat Insights

# Complementary intelligence
Red Hat Insights:      SaaS security analysis & recommendations
Universal DataLoader:  Local knowledge graph & Graph RAG

# Combined benefits:
insights_data = insights_api.get_vulnerabilities()
local_graph = dataloader.create_knowledge_graph()
intelligent_ops = combine_insights_with_graph_rag(insights_data, local_graph)

Scenario 2: With Centralized Logging (Splunk/ELK)

# Enhanced log intelligence  
Splunk/ELK:           Centralized log storage & search
Universal DataLoader: AI-powered relationship extraction

# Graph RAG queries become possible:
"Which servers have both SSH failures AND vulnerable packages?"
"Show dependency chain for services affected by security patches"

Scenario 3: With Monitoring Stack (Prometheus/Grafana)

# Infrastructure intelligence
Prometheus/Grafana:   Metrics monitoring & dashboards
Universal DataLoader: Semantic understanding of infrastructure

# Intelligent correlation:
"Which high-CPU systems also have recent package vulnerabilities?"
"Show service dependencies for systems with memory alerts"

🎯 Production Deployment Integration

Minimal Infrastructure Impact

# Resource requirements
CPU Usage:    Low - only during batch processing
Memory:       2-4GB during knowledge graph creation  
I/O Impact:   Read-only file access, no write operations
Network:      LLM API calls only (configurable endpoints)
Storage:      No additional storage on monitored systems

Security & Compliance

# Maintains enterprise security standards
Data Access:     Read-only filesystem access
API Keys:        Externalized configuration (environment variables)
Audit Trail:     All operations logged
Network:         Configurable endpoints (on-premise LLM support planned)
Encryption:      Data in transit encrypted (HTTPS/TLS)

πŸš€ Future Integration Roadmap

Phase 1: API Integrations

# Direct API consumption (no file system access)
red_hat_insights_api:
  vulnerabilities: "/api/insights/v1/vulnerabilities"
  compliance: "/api/insights/v1/compliance" 
  recommendations: "/api/insights/v1/advisor"

splunk_api:
  search: "/services/search/jobs"
  saved_searches: "/services/saved/searches"
  
elasticsearch_api:
  search: "/_search"
  indices: "/_cat/indices"

Phase 2: Enterprise Connectors

# Native integrations
satellite_connector:
  systems_inventory: "satellite.example.com/api/v2/hosts"
  package_management: "satellite.example.com/api/v2/packages"

prometheus_connector:
  metrics_query: "prometheus.example.com/api/v1/query"
  alert_rules: "prometheus.example.com/api/v1/rules"

**Phase 3: Enterprise Features **

# Enterprise-grade capabilities  
rbac_integration:
  active_directory: "LDAP/AD authentication"
  role_based_access: "Fine-grained permissions"
  
audit_compliance:
  sox_compliance: "Financial audit trails"
  hipaa_compliance: "Healthcare data protection"
  gdpr_compliance: "Data privacy controls"

πŸ“‹ Integration Checklist

Before Deployment

  • Identify data sources: Which logs/configs to analyze
  • Verify permissions: Read-only access to target files
  • Network access: LLM API endpoints reachable
  • Resource planning: 4-8GB RAM for processing
  • Security review: API key management strategy

During Deployment

  • Start with test data: Use simulated systems first
  • Validate knowledge graph: Check entity extraction quality
  • Test Graph RAG queries: Verify intelligent responses
  • Monitor resource usage: CPU, memory, network impact
  • Security audit: Review API key security

Post-Deployment

  • Integration testing: Verify compatibility with existing tools
  • Performance monitoring: Track processing times and accuracy
  • User training: Enable teams to use Graph RAG capabilities
  • Expand data sources: Add more systems incrementally
  • Plan API integrations: Connect to enterprise APIs

πŸ’‘ Best Practices for Enterprise Integration

1. Phased Rollout Strategy

# Recommended deployment approach
Phase 1: Development β†’ Test with simulated data
Phase 2: Staging    β†’ Small subset of real systems  
Phase 3: Production β†’ Full enterprise deployment
Phase 4: Integration β†’ Connect to enterprise APIs

2. Data Source Strategy

# Start with low-risk, high-value data
Tier 1: System info files (static data)
Tier 2: Historical logs (archived data)  
Tier 3: Current logs (operational data)
Tier 4: Real-time streams (future capability)

3. Security & Governance

# Enterprise security alignment
Data Classification: Treat as internal/confidential
API Key Management: Use enterprise secret management
Access Controls: Implement least-privilege access
Audit Requirements: Log all data access operations

πŸš€ Usage

Basic Knowledge Graph Creation

from core.unified_dataloader import get_universal_loader

# Create and load systems
loader = get_universal_loader()
systems, events = loader.load_all_systems()

print(f"Created knowledge graph with {len(systems)} systems")
loader.close()

Custom Data Sources

# Point to your infrastructure data
config = {
    "data_sources": {
        "your_data": {
            "type": "filesystem",
            "base_path": "/path/to/your/logs",
            "file_patterns": {
                "logs": ["**/*.log", "**/*.txt"],
                "configs": ["**/*.conf", "**/*.yaml"]
            }
        }
    }
}

loader = get_universal_loader(config=config)
systems, events = loader.load_all_systems()

Querying the Knowledge Graph

# Execute intelligent Cypher queries
result = loader.neo4j_graph.query("""
    MATCH (s:Server)-[:RUNS]->(svc:Service)
    WHERE s.environment = 'production'
    RETURN s.name, svc.name, svc.status
""")

for record in result:
    print(f"Server: {record['s.name']}, Service: {record['svc.name']}")

Scale Testing with Generated Data

from utils.rhel_filesystem_generator import RHELFilesystemGenerator

# Generate enterprise-scale test data
generator = RHELFilesystemGenerator(num_systems=100)
generator.generate_all_systems()
print(" Generated 100 enterprise RHEL systems")

πŸ“– API Reference

Core Classes

UnifiedDataLoader

class UnifiedDataLoader:
    def load_all_systems(self) -> Tuple[List[SystemEntity], List[EventEntity]]
        """Load all systems and create knowledge graph"""
        
    def load_system(self, system_id: str) -> Tuple[SystemEntity, List[EventEntity]]
        """Load specific system"""
        
    def close(self) -> None
        """Cleanup connections"""

RHELFilesystemGenerator

class RHELFilesystemGenerator:
    def __init__(self, num_systems: int = 5)
    def generate_all_systems(self) -> Dict[str, Dict]
        """Generate realistic RHEL systems"""

Configuration Classes

UnifiedConfigLoader

class UnifiedConfigLoader:
    def get_llm_config(self) -> Dict[str, Any]
    def get_neo4j_config(self) -> Dict[str, Any]
    def get_dataloader_config(self) -> Dict[str, Any]

Data Models

@dataclass
class SystemEntity:
    system_id: str
    hostname: str
    environment: str
    services: List[str]
    metadata: Dict[str, Any]

@dataclass  
class EventEntity:
    event_id: str
    system_id: str
    event_type: str
    timestamp: datetime
    description: str
    metadata: Dict[str, Any]

πŸ§ͺ Testing

Run Test Suite

# Activate environment
source .venv/bin/activate

# Run all tests
python -m pytest tests/ -v

# Run with coverage
python -m pytest tests/ --cov=core --cov=config --cov=utils

# Quick setup verification  
python test_setup.py  # Should show 5/5 tests pass

Integration Testing

# Test with generated data
python utils/rhel_filesystem_generator.py 10
python tests/test_complete_4phase_pipeline.py

Performance Testing

# Benchmark with scale data
python utils/rhel_filesystem_generator.py 1000
time python -c "
from core.unified_dataloader import get_universal_loader
loader = get_universal_loader()
systems, events = loader.load_all_systems()
print(f'Processed {len(systems)} systems')
loader.close()
"

🀝 Contributing

We welcome contributions! Please follow these guidelines:

Development Setup

# Fork repo, then:
git clone https://github.com/YOUR-USERNAME/dataloader.git
cd dataloader

# Setup development environment
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

# Create feature branch
git checkout -b feature/your-feature

Contribution Process

  1. 🍴 Fork the repository
  2. 🌿 Create feature branch from main
  3. ** Add tests** for new functionality
  4. πŸ§ͺ Ensure tests pass: python -m pytest tests/ -v
  5. πŸ“ Update documentation as needed
  6. πŸ’« Create pull request with clear description

Code Standards

  • Style: Follow PEP 8, use black formatter
  • Tests: Maintain >90% test coverage
  • Documentation: Update README and docstrings
  • Commits: Use conventional commit format

Areas for Contribution

  • πŸ”Œ Data Source Adapters: APIs, databases, cloud storage
  • 🎯 Domain Templates: Healthcare, finance, manufacturing
  • πŸ§ͺ Testing: Performance tests, edge cases
  • πŸ“š Documentation: Tutorials, examples, guides
  • ⚑ Performance: Optimization, parallel processing

πŸ› Troubleshooting

Common Issues

Neo4j Connection Problems

# Check if Neo4j is running
lsof -i :7687

# Verify credentials
echo $NEO4J_PASSWORD  # Should be 'password'

LLM API Issues

# Verify API configuration
echo $OPENAI_API_KEY
echo $OPENAI_BASE_URL

# Test connection
python -c "from langchain_openai import ChatOpenAI; print(' LLM working')"

Data Loading Issues

# Generate sample data
python utils/rhel_filesystem_generator.py

# Check file permissions
ls -la simulated_rhel_systems/

Performance Issues

  • Slow processing: Reduce batch size, check network latency
  • Memory errors: Increase system memory or reduce dataset size
  • Neo4j issues: Ensure APOC plugin installed, check database status

Getting Help

  1. πŸ“– Check documentation and troubleshooting section
  2. πŸ” Search existing issues on GitHub
  3. πŸ› Create detailed issue with environment details and logs
  4. πŸ’¬ Join discussions for questions and community support

πŸ“Š Performance

Benchmarks

Systems Processing Time Entities Created Memory Usage
5 45 seconds ~45 entities 1.2GB
50 8 minutes ~450 entities 2.1GB
100 15 minutes ~900 entities 2.8GB
1000 3.5 hours ~9000 entities 4.2GB

Limitations

  • Data Sources: Filesystem only (APIs/databases planned)
  • File Size: Large files (>50MB) may need chunking
  • Languages: Optimized for English text
  • LLM Dependency: Requires internet connection for AI processing

Scalability

  • Maximum tested: 1000 systems (15K entities, 12K relationships)
  • Rate limits: Depends on LLM provider (~100 requests/minute)
  • Hardware requirements: 8GB RAM recommended for 1000+ systems

πŸ”§ Technical Deep Dive

Why LLMs Are Essential

Traditional log parsing uses rigid patterns:

# Regex approach (limited)
"httpd\[(\d+)\]: (.+)" β†’ Extract PID and message
#  Misses context, relationships, semantic meaning

LLMs provide semantic intelligence:

# AI approach (intelligent)
"systemd[1]: Started The Apache HTTP Server"
#  Understands: Apache = httpd service
#  Infers: systemd MANAGES httpd
#  Connects: Related to ports 80/443, SSL, web traffic

AI Entity Extraction Process

Input: RHEL System Files

system/
β”œβ”€β”€ /etc/redhat-release     β†’ Server entity (version, architecture)
β”œβ”€β”€ /var/log/messages       β†’ Service events, system activities
β”œβ”€β”€ /var/log/secure         β†’ User activities, authentication
β”œβ”€β”€ /var/log/yum.log        β†’ Package installations/updates
β”œβ”€β”€ /etc/httpd/conf/        β†’ Service configurations
└── /var/lib/insights/      β†’ Security findings, vulnerabilities

AI Recognition Patterns

πŸ–₯️ Server Entities:

# From: /etc/redhat-release
"Red Hat Enterprise Linux release 9.3"
# AI extracts β†’
Server {
    name: "web-prod-01",
    rhel_version: "9.3",
    environment: "production"
}

βš™οΈ Service Entities:

# From: /var/log/messages
"systemd[1]: Started The Apache HTTP Server"
# AI extracts β†’
Service {
    name: "httpd",
    status: "active",
    managed_by: "systemd"
}

πŸ”— Intelligent Relationships:

# AI automatically creates:
(web-prod-01:Server)-[:RUNS]->(httpd:Service)
(httpd:Service)-[:USES]->(httpd-package:Package)
(httpd:Service)-[:DEPENDS_ON]->(openssl:Package)

Graph RAG Capabilities

With LLM-extracted graphs, you can ask:

"Which production web servers have SSL configuration issues?"
"Show me dependency chains for services with recent security patches"
"What would be impacted if I restart the MySQL service?"

The AI creates semantic relationships that enable sophisticated queries impossible with traditional parsing.


πŸ“„ License

Licensed under the Apache License 2.0 - see LICENSE file.

Summary: Commercial use, modification, distribution allowed. ❗ License notice required.


πŸ™ Acknowledgments

Built With:

Contributors:


🌟 Star this project if it helps you build intelligent infrastructure graphs!

πŸ“¬ Questions? Open an issue or discussion.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors